package com.ruoyi.project.hissystem.controller;

import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.hissystem.domain.HisMenu;
import com.ruoyi.project.hissystem.service.HisMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : 杨磊
 * @date : 15:29 2021/8/19
 */
@RestController
@RequestMapping("/hissystem/menu")
public class HisMenuController extends BaseController {

    //声明业务层属性
    @Autowired
    private HisMenuService hisMenuService;

     //获取菜单列表信息
    @PreAuthorize("@ss.hasPermi('hissystem:menu:list')")
    @GetMapping("/list")
    public AjaxResult list(HisMenu menu)
    {

        List<HisMenu> menus = hisMenuService.selectMenuList(menu);
        return AjaxResult.success(menus);
    }

    //新增菜单信息
    @PreAuthorize("@ss.hasPermi('hissystem:menu:add')")
    @Log(title = "菜单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HisMenu menu){
        return toAjax(hisMenuService.insertMenu(menu));
    }


}
